package com.kj.tms.common.bean.service;


import com.kj.pagehelper.PageHelper;
import com.kj.tms.common.bean.dao.BaseMapper;
import com.kj.tms.common.bean.dto.BaseDto;
import com.kj.tms.common.bean.dto.Pager;

public abstract class BaseService<T extends BaseDto> {

    public abstract BaseMapper<T> getMapper();

    /**
     * 分页查询
     *
     * @param model
     * @return
     * @see [类、类#方法、类#成员]
     */
    public Pager selectPage(BaseDto model) {
        Pager pager = model.getPager();
        //查询
        int pageNo = pager.getPageNo();
        int pageSize = pager.getPageSize();
        PageHelper.startPage(pageNo, pageSize);
        pager.setResults(getMapper().listByCondition(model));
        pager.setRowCount(getMapper().getCounts(model));
        return pager;
    }


}
